// pages/cat/cat.js
const { getCart,delGoodsCart } = require("../api/index")
Page({

  data: {
    cartData:[]
  },

  onLoad(options) {
  },
  onShow(){
    this.http()
  },
  http(){
    getCart().then(res =>{
      console.log(res)
      if(res.data.status === 200){
        this.setData({
          cartData:res.data.data
        })
      }
    })
  },
  //删除购物车信息
  delCartHandle(e){
    // console.log(e.currentTarget.dataset.id)
    delGoodsCart({currentID:e.currentTarget.dataset.id}).then(res =>{
      if(res.data.status === 200 ){
        this.http()
        wx.showToast({
          title: '删除成功',
        })
        
      }else{
        wx.showToast({
          title: '删除失败',
        })
      }
    })
  }

})